//
//  QLPublishSetPriceCell.m
//  谁约
//
//  Created by qlwl on 16/10/20.
//  Copyright © 2016年 qlwl. All rights reserved.
//

#import "QLPublishSetPriceCell.h"

@implementation QLChooseSKillPayTypeCell
- (IBAction)offLineBtnClick:(id)sender {
    if (self.selectOffOrOnLine) {
        self.type = @"1";
        self.selectOffOrOnLine(self.type);
    }
}
- (IBAction)onLineBtnClick:(id)sender {
    if (self.selectOffOrOnLine) {
        self.type = @"0";
        self.selectOffOrOnLine(self.type);
    }
}
- (void)setType:(NSString *)type // 0, 1
{
    if (_type!=type) {
        _type = type;
        if (![_type isEqualToString:@"0"]) {// 默认是0
            self.offLineBtn.selected = YES;
            self.onLineBtn.selected = NO;
        }else{
            self.offLineBtn.selected = NO;
            self.onLineBtn.selected = YES;
        }
    }
}
@end

@implementation QLPublishSetTimeCell : UITableViewCell
- (IBAction)setBtnClick:(id)sender {
    if (self.setBtnClick) {
        self.setBtnClick();
    }
}

@end


@interface QLPublishChooseUnitPriceCell ()
@property (weak, nonatomic) IBOutlet UIButton *btn1;
@property (weak, nonatomic) IBOutlet UIButton *btn2;
@property (weak, nonatomic) IBOutlet UIButton *btn3;
@property (weak, nonatomic) IBOutlet UIButton *btn4;
@property (nonatomic, strong) NSArray * btnsArray ; //

@end
@implementation QLPublishChooseUnitPriceCell : UITableViewCell
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _btnsArray = @[self.btn1,self.btn2,self.btn3,self.btn4];
}
- (void) setSelectType:(ChooseUnitPriceType)selectType
{
    _selectType = selectType;
    for (UIButton * btn in _btnsArray) {
        btn.selected = NO;
        btn.userInteractionEnabled = YES;
    }
    if (_selectType<= _btnsArray.count) {
        UIButton *btn = _btnsArray[_selectType-1];
        btn.selected = YES;
        btn.userInteractionEnabled = NO;
    }
    
}

- (IBAction)btn1Click:(id)sender {
    if (self.selectBtn) {
        self.selectBtn(UnitPriceType1);
        self.selectType = UnitPriceType1;
    }
    
}
- (IBAction)btn2Click:(id)sender {
    if (self.selectBtn) {
        self.selectBtn(UnitPriceType2);
        self.selectType = UnitPriceType2;
    }
}
- (IBAction)btn3Click:(id)sender {
    if (self.selectBtn) {
        self.selectBtn(UnitPriceType3);
        self.selectType = UnitPriceType3;
    }
}
- (IBAction)btn4Click:(id)sender {
    if (self.selectBtn) {
        self.selectBtn(UnitPriceType4);
        self.selectType = UnitPriceType4;
    }
}

@end

@implementation QLPublishSetPriceCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)priceFieldInput:(id)sender {
    UITextField * field = sender;
    if (self.inputPrice) {
        self.inputPrice(field.text);
    }
}

@end
